﻿#This creates the definition for the resource
Import-Module xDSCResourceDesigner

$dscResourceName = "MESF_cCertificateDeployment"
$dscResourceFriendlyName = "cCertificateDeployment"

$scriptPath = $PSCommandPath
$scriptfile = Get-Item -Path $scriptPath

$schemaMofFile = $scriptfile.Directory.Parent.FullName

write-host "Start generating $schemaMofFile" -ForegroundColor Green

#The certificate file path to import in the cacert
$CertificateFilePath = New-xDscResourceProperty -Name CertificateFilePath -Type String -Attribute Required

#The certificate thumbprint
$CertificateThumbprint = New-xDscResourceProperty -Name CertificateThumbprint -Type String -Attribute Required

#The certificate Alias
$CertificateAlias = New-xDscResourceProperty -Name CertificateAlias -Type String -Attribute Key

#The java location used to call Keytool
$JavaFolderPath = New-xDscResourceProperty -Name JavaFolderPath -Type String -Attribute Required

#The java cacert location where certificate will be added or removed
$JavaKeystorePath = New-xDscResourceProperty -Name JavaKeystorePath -Type String -Attribute Write

#The java cacert password
$JavaKeystorePassword = New-xDscResourceProperty -Name JavaKeystorePassword -Type String -Attribute Write

#Identify if the action is to create the share or remove the share (i.e. should it be present or absent)
$Ensure    = New-xDscResourceProperty -Name Ensure -Type String -Attribute Write -ValidateSet "Present", "Absent"

#Create the actual resource
New-xDscResource -Name $dscResourceName -Property $CertificateFilePath, $CertificateThumbprint, $CertificateAlias, $JavaFolderPath, $JavaKeystorePath, $JavaKeystorePassword, $Ensure -Path $schemaMofFile -FriendlyName $dscResourceFriendlyName

write-host "End generating $schemaMofFile" -ForegroundColor Green
